﻿<%@ Page Title="Profile - Traditional Maltese Cuisine" Language="C#" MasterPageFile="~/MainMasterPage.Master" AutoEventWireup="true" CodeBehind="Profile.aspx.cs" Inherits="TraditionalMalteseCuisine.Profile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <asp:ValidationSummary ID="vsyValidationSummary" runat="server" HeaderText="Please note that:" CssClass="validation_summary" />
    <asp:Label ID="lblMessage" runat="server" CssClass="successful_message" Visible="false" Text="Profile updated successfully" />
    <div id="control_wrapper" style="width: 60%;">
        <table style="width: 100%;">
            <tr>
                <td colspan="6">
                <div class="title"><% Response.Write(string.Format("{0}'s", CurrentProfile)); %> Profile</div>
                <% if ((!IsOwner) && (IsLoggedIn)) { %>
                <asp:LinkButton ID="btnUnsubscribe" runat="server" CssClass="button unsubscribe_button" CausesValidation="False" Text="Unsubscribe" Visible="False" OnClick="btnUnsubscribe_Click" />
                <asp:LinkButton ID="btnSubscribe" runat="server" CssClass="button subscribe_button" CausesValidation="False" Text="Subscribe" Visible="True" OnClick="btnSubscribe_Click" />
                <% } %>
                </td>
            </tr>
            <% if (IsOwner) { %>
            <tr><td colspan="6" class="label"><a href="newrecipe.aspx">Upload a New Recipe</a></td></tr>
            <% } %>
            <tr><td colspan="6">&nbsp;</td></tr>
            <tr>
                <td rowspan="14" colspan="2" class="top_center" style="padding: 10px;">
                    <img src='<% Response.Write(CurrentProfile.ImageLocation); %>' alt='<% Response.Write(string.Format("{0}'s", CurrentProfile)); %>' style="max-width: 250px" />
                    <% if (IsOwner) { %>
                        <asp:FileUpload ID="uplImageLocation" runat="server" CssClass="textbox" />
                        <asp:CustomValidator ID="csvImageLocation" runat="server" ErrorMessage="Please choose a valid image file" ControlToValidate="uplImageLocation">&nbsp;*</asp:CustomValidator>
                    <% } %>
                </td>
                <td rowspan="14">&nbsp;</td>
                <td class="label">First Name:</td>
                <% if (IsOwner) { %>
                <td class="middle_left" style="width: 60%;"><asp:TextBox ID="txtFirstName" runat="server" CssClass="textbox" /></td>
                <td class="middle_left"><asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ErrorMessage="First Name field cannot be empty" ControlToValidate="txtFirstName" SetFocusOnError="True" >*</asp:RequiredFieldValidator></td>
                <% } else { %>
                <td class="textbox"><p><% Response.Write(CurrentProfile.FirstName); %></p></td>
                <% } %>
            </tr>
            <tr>
                <td class="label">Last Name:</td>
                <% if (IsOwner) { %>
                <td class="middle_left" style="width: 60%;"><asp:TextBox ID="txtLastName" runat="server" CssClass="textbox" /></td>
                <td class="middle_left"><asp:RequiredFieldValidator ID="rfvLastName" runat="server" ErrorMessage="Last Name field cannot be empty" ControlToValidate="txtLastName" SetFocusOnError="True" >*</asp:RequiredFieldValidator></td>
                <% } else { %>
                <td class="textbox"><p><% Response.Write(CurrentProfile.LastName); %></p></td>
                <% } %>
            </tr>
            <tr>
                <td class="label">Gender:</td>
                <% if (IsOwner) { %>
                <td class="middle_left" style="width: 60%;"><asp:DropDownList ID="cmbGender" runat="server" CssClass="combobox" >
                    <asp:ListItem>Not Specified</asp:ListItem>
                    <asp:ListItem>Male</asp:ListItem>
                    <asp:ListItem>Female</asp:ListItem>
                    <asp:ListItem>Other</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="middle_left">&nbsp;</td>
                <% } else { %>
                <td class="textbox"><p><% Response.Write(CurrentProfile.Gender); %></p></td>
                <% } %>
            </tr>
            <tr>
                <td class="label">E-Mail Address:</td>
                <% if (IsOwner) { %>
                <td class="middle_left" style="width: 60%;"><asp:TextBox ID="txtEMail" runat="server" CssClass="textbox" /></td>
                <td class="middle_left"><asp:RequiredFieldValidator ID="rfvEMail" runat="server" ErrorMessage="E-Mail field cannot be empty" ControlToValidate="txtEMail" SetFocusOnError="True" >*</asp:RequiredFieldValidator><asp:CustomValidator ID="csvEMailExists" runat="server" ErrorMessage="E-Mail already exists" ControlToValidate="txtEmail">*</asp:CustomValidator></td>
                <% } else { %>
                <td class="textbox"><p><a href='mailto:<% Response.Write(CurrentProfile.EMail); %>'><% Response.Write(CurrentProfile.EMail); %></a></p></td>
                <% } %>
            </tr>
            <tr><td colspan="6">&nbsp;</td></tr>
            <% if (IsOwner) { %>
            <tr>
                <td class="middle_right"><asp:Label ID="lblCurrentPassword" runat="server" Text="Current Password:" CssClass="label" /></td>
                <td class="middle_left" style="width: 60%;"><asp:TextBox ID="txtCurrentPassword" runat="server" TextMode="Password" CssClass="textbox" /></td>
                <td class="middle_left"><asp:CustomValidator ID="csvCurrentPassword" runat="server" ErrorMessage="Current password is incorrect" ControlToValidate="txtCurrentPassword" SetFocusOnError="True" >*</asp:CustomValidator></td>
            </tr>
            <tr>
                <td class="middle_right"><asp:Label ID="lblPassword" runat="server" Text="Password:" CssClass="label" /></td>
                <td class="middle_left" style="width: 60%;"><asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="textbox" /></td>
                <td class="middle_left"><asp:CustomValidator ID="csvPassword" runat="server" ErrorMessage="Password field cannot be empty" ControlToValidate="txtPassword" SetFocusOnError="True" >*</asp:CustomValidator></td>
            </tr>
            <tr>
                <td class="middle_right"><asp:Label ID="lblPassword2" runat="server" Text="Re-Type Password:" CssClass="label" /></td>
                <td class="middle_left" style="width: 60%;"><asp:TextBox ID="txtPassword2" runat="server" TextMode="Password" CssClass="textbox" /></td>
                <td class="middle_left"><asp:CustomValidator ID="csvPassword2" runat="server" ErrorMessage="Password 2 field cannot be empty" ControlToValidate="txtPassword2" SetFocusOnError="True" >*</asp:CustomValidator><asp:CompareValidator ID="cfvPasswordsCompare" runat="server" ErrorMessage="Passwords do not match" ControlToCompare="txtPassword" ControlToValidate="txtPassword2">*</asp:CompareValidator></td>
            </tr>
            <tr><td colspan="6">&nbsp;</td></tr>
            <% } %>
            <tr>
                <td class="label">Level For Recipes Posted:</td>
                <td class="textbox" colspan="2"><a href="BoardLeadersInPostedRecipes.aspx" style="text-decoration: none;"><% Response.Write(GetContributionLevelForRecipesPosted()); %></a></td>
            </tr>
            <tr>
                <td class="label">Total Recipes Posted:</td>
                <td class="textbox" colspan="2"><a href='<% Response.Write(string.Format("recipes.aspx?user={0}", CurrentProfile.ID)); %>'><% Response.Write(GetTotalRecipesPosted()); %></a></td>
            </tr>
            <tr><td colspan="6">&nbsp;</td></tr>
            <tr>
                <td class="label">Level For Recipes Commented:</td>
                <td class="textbox" colspan="2"><a href="BoardLeadersInPostedRecipesComments.aspx" style="text-decoration: none;"><% Response.Write(GetContributionLevelForRecipesCommentsPosted()); %></a></td>
            </tr>
            <tr>
                <td class="label">Total Recipes Commented:</td>
                <td class="textbox" colspan="2"><b><% Response.Write(GetTotalRecipesCommentsPosted()); %></b></td>
            </tr>
            <tr><td colspan="6">&nbsp;</td></tr>
            <% if (IsOwner) { %>
            <tr><td colspan="6" class="middle_right"><asp:Button ID="btnUpdate" runat="server" Text="Update" CssClass="button" OnClick="btnUpdate_Click" /></td></tr>
            <% } %>
        </table>
        <% if ((!IsOwner) && (((System.Data.DataTable)dgvMostLiked.DataSource) != null) && (((System.Data.DataTable)dgvMostLiked.DataSource).Rows.Count > 0)) { %>
        <br />
        <hr style="width: 85%;" />
        <br />
        <asp:UpdatePanel ID="updMostLikedPanel" runat="server">
            <ContentTemplate>
            <p class="label" style="float:right; text-align: justify;">Show top <asp:DropDownList ID="cmbMaxLikedRecords" runat="server" CssClass="combobox" Width="40px" AutoPostBack="True" OnSelectedIndexChanged="cmbMaxLikedRecords_SelectedIndexChanged">
                <asp:ListItem>3</asp:ListItem>
                <asp:ListItem>6</asp:ListItem>
                <asp:ListItem>9</asp:ListItem>
                <asp:ListItem>12</asp:ListItem>
                </asp:DropDownList> recipes</p>
            <p class="label" style="text-align: justify;">Mostly famous for:</p>
            <asp:Repeater ID="dgvMostLiked" runat="server">
                <HeaderTemplate><div id="preview_listing" style="background-color: rgba(0, 0, 0, 0); border: 0; box-shadow: none;"></HeaderTemplate>
                <ItemTemplate>
                    <div id="preview_row" title='<%# string.Format("{0} member(s) like this!", Eval("TotalLikes")) %>' style="width: 29%;">
                        <a href='<%# string.Format("details.aspx?item={0}", Eval("recipe_id")) %>'>
                            <div id="preview_row_header">
                                <%# Eval("recipe_name") %>
                            </div>
                            <div id="preview_row_content">
                                <img src='<%# Eval("thumbnail_location") %>' alt="Click for more details..." class="thumbnail_image" />
                            </div>
                        </a>
                        <div id="preview_row_footer">
                            by <a href='<%# string.Format("profile.aspx?user={0}", Eval("member_id")) %>'><%# string.Format("{0} {1}", Eval("firstname"), Eval("lastname")) %></a>
                        </div>
                    </div>
                </ItemTemplate>
                <FooterTemplate></div></FooterTemplate>
            </asp:Repeater>
            </ContentTemplate>
        </asp:UpdatePanel>
        <% } %>
        <br />
    </div>
</asp:Content>